package com.first.nell.info.cotediva

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.first.nell.base.BaseViewModel
import com.first.nell.data.*
import com.first.nell.network.ApiUserReposity

/** 科特钱包viewModel */
class WalletInfoViewModel : BaseViewModel() {

    /** 钱包列表 */
    val mFirstNellWalletFirstNellList = mutableListOf<RevObjWalletListFcfa>()

    /** 获取钱包列表 */
    private val mFirstNellGetFirstNellWalletFirstNellListFirstNellFCFAFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 保存钱包 */
    private val mFirstNellSaveFirstNellWalletFirstNellFCFAFirstNellLiveData =
        MutableLiveData<ReqSaveWalletFcFa>()

    /** 删除钱包 */
    private val mFirstNellDeleteFirstNellWalletFirstNellFCFAFirstNellLiveData =
        MutableLiveData<ReqDeleteWalletFcfa>()

    /** 保存钱包认证状态 */
    private val mFirstNellSaveFirstNellBvnFirstNellFCFAFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取钱包列表 */
    val onFirstNellFetchFirstNellWalletFirstNellListFirstNellFCFAFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellGetFirstNellWalletFirstNellListFirstNellFCFAFirstNellLiveData
        ) { query ->
            ApiUserReposity.getFirstNellWalletFirstNellListFirstNellFCFA(this, query)
        }

    /** 保存钱包 */
    val onFirstNellSaveFirstNellWalletFirstNellFCFAFirstNellLiveData =
        Transformations.switchMap(mFirstNellSaveFirstNellWalletFirstNellFCFAFirstNellLiveData) { query ->
            ApiUserReposity.saveFirstNellWalletFirstNellFCFA(this, query)
        }

    /** 删除钱包 */
    val onFirstNellDeleteFirstNellWalletFirstNellFCFAFirstNellLiveData =
        Transformations.switchMap(mFirstNellDeleteFirstNellWalletFirstNellFCFAFirstNellLiveData) { query ->
            ApiUserReposity.deleteFirstNellWalletFirstNellFCFA(this, query)
        }

    /** 保存钱包认证状态 */
    val onFirstNellSaveFirstNellBvnFirstNellFCFAFirstNellLiveData =
        Transformations.switchMap(mFirstNellSaveFirstNellBvnFirstNellFCFAFirstNellLiveData) { query ->
            ApiUserReposity.saveFirstNellBvnFirstNellFCFA(this, query)
        }

    /** 获取钱包列表 */
    fun getFirstNellWalletFirstNellListFirstNellFCFA(reqBase: ReqBase = ReqBase()) {
        mFirstNellGetFirstNellWalletFirstNellListFirstNellFCFAFirstNellLiveData.value = reqBase
    }

    /** 保存钱包 */
    fun saveFirstNellWalletFirstNellFCFA(reqSaveWalletFcFa: ReqSaveWalletFcFa) {
        mFirstNellSaveFirstNellWalletFirstNellFCFAFirstNellLiveData.value = reqSaveWalletFcFa
    }

    /** 删除钱包 */
    fun deleteFirstNellWalletFirstNellFCFA(reqDeleteWalletFcfa: ReqDeleteWalletFcfa) {
        mFirstNellDeleteFirstNellWalletFirstNellFCFAFirstNellLiveData.value = reqDeleteWalletFcfa
    }

    /** 保存钱包认证状态 */
    fun saveFirstNellBvnFirstNellFCFA(reqBase: ReqBase) {
        mFirstNellSaveFirstNellBvnFirstNellFCFAFirstNellLiveData.value = reqBase
    }

    /** 初始化钱包列表 */
    fun initFirstNellWalletFirstNellListFirstNellFCFA(list: List<RevObjWalletListFcfa>) {
        mFirstNellWalletFirstNellList.clear()
        mFirstNellWalletFirstNellList.addAll(list)
    }
}